luci-base: ui.js: avoid error tooltips overlapping dropdowns
authorJo-Philipp Wich <[email protected]>
Thu, 9 Dec 2021 14:28:39 +0000 (15:28 +0100)
committerJo-Philipp Wich <[email protected]>
Tue, 15 Feb 2022 23:51:11 +0000 (00:51 +0100)
Fixes: #5588
Signed-off-by: Jo-Philipp Wich <[email protected]>
(cherry picked from commit 604c00905987cf38336754aef408d837b368a8e5)

modules/luci-base/htdocs/luci-static/resources/ui.js

index 0e909b6dcc717dbfd76d25930f1b69300f3a976a..20ef91117bb5c26e71a7499d804c123708f66d48 100644 (file)
@@ -3236,7 +3236,8 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
 
                var rect = target.getBoundingClientRect(),
                    x = rect.left              + window.pageXOffset,
-                   y = rect.top + rect.height + window.pageYOffset;
+                   y = rect.top + rect.height + window.pageYOffset,
+                   above = false;
 
                tooltipDiv.className = 'cbi-tooltip';
                tooltipDiv.innerHTML = '▲ ';
@@ -3245,7 +3246,15 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
                if (target.hasAttribute('data-tooltip-style'))
                        tooltipDiv.classList.add(target.getAttribute('data-tooltip-style'));
 
-               if ((y + tooltipDiv.offsetHeight) > (window.innerHeight + window.pageYOffset)) {
+               if ((y + tooltipDiv.offsetHeight) > (window.innerHeight + window.pageYOffset))
+                       above = true;
+
+               var dropdown = target.querySelector('ul.dropdown[style]:first-child');
+
+               if (dropdown && dropdown.style.top)
+                       above = true;
+
+               if (above) {
                        y -= (tooltipDiv.offsetHeight + target.offsetHeight);
                        tooltipDiv.firstChild.data = '▼ ' + tooltipDiv.firstChild.data.substr(2);
                }